//
//  BIDSuggestAboutAPPViewController.m
//  HJGJCommunity
//
//  Created by mal on 2017/6/21.
//  Copyright © 2017年 mal. All rights reserved.
//

#import "BIDSuggestAboutAPPViewController.h"
#import "BIDCustomTextView.h"

static NSString *submitURL = @"suggestAndroid/add.action";

@interface BIDSuggestAboutAPPViewController ()

@end

@implementation BIDSuggestAboutAPPViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.title = @"帮助与反馈";
    _textView.placeholder = @"请输入您的意见和建议，我们会及时处理...";
    _textView.inputAccessoryView = self.toolBar;
    _btn.clipsToBounds = YES;
    _btn.layer.cornerRadius = 3.f;
    [self.view setBackgroundColor:RGBACOLOR(230, 230, 237, 1.f)];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)alertViewHandler
{
    [self.navigationController popViewControllerAnimated:YES];
}

- (IBAction)submitBtnHandler:(id)sender
{
    NSString *strContent = _textView.text;
    if(strContent.length == 0)
    {
        [self showAlertView:@"" buttonTitle:ALERT_BTN_TITLE tag:0 functionName:nil];
        return;
    }
    NSString *strRequestURL = [[NSString alloc] initWithFormat:@"%@/%@", [AppDelegate getServerAddr], submitURL];
    NSString *strPost = [[NSString alloc] initWithFormat:@"suggest.content=%@&memberId=%@", strContent, [AppDelegate getUserId]];
    [self sendHttpRequestWithURL:strRequestURL postData:strPost withCompletion:^(NSDictionary *responseDic, NSString *errMsg){
        if(errMsg)
        {
            [self showAlertView:errMsg buttonTitle:ALERT_BTN_TITLE tag:0 functionName:nil];
        }
        else
        {
            [self showAlertView:@"提交成功" buttonTitle:ALERT_BTN_TITLE tag:@100 functionName:@"alertViewHandler"];
        }
    }];
}

@end
